package servlet;

import dao.UserDaoImpl;
import impl.BaoDaoserviceImpl;
import pojo.AirQualityIndex;
import service.BaoDaoservice;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/addServlet")
public class addServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        AirQualityIndex air = new AirQualityIndex();

        String districtId = request.getParameter("quyu");
        String monitorTime = request.getParameter("monitorTime");
        int pm10 = Integer.parseInt(request.getParameter("pm10"));
        int pm25 = Integer.parseInt(request.getParameter("pm10"));
        String monitoringStation = request.getParameter("monitoringStation");

            BaoDaoservice aq =  new BaoDaoserviceImpl();
            air.setDistrictId(districtId);
            air.setMonitorTime(monitorTime);
            air.setPm10(pm10);
            air.setPm25(pm25);
            air.setMonitoringStation(monitoringStation);
            aq.add(air);
        response.sendRedirect("indexSelect");


    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}